package buffer.learn;

import java.nio.ByteBuffer;
import java.util.Arrays;

/**
 * @author chenxin
 * @time 2016-12-24-11:02
 */
public class ByteBufferTest {
    public static void main(String[] args) {
        byte[] bytes = new byte[4];
        ByteBuffer buffer = ByteBuffer.wrap(bytes);

        buffer.putInt(0x12345678);
        // [18, 52, 86, 120]
        System.out.println(Arrays.toString(bytes));

        bytes[0] = 1;

        // 1
        buffer.flip();
        System.out.println(buffer.get());
        System.out.println(buffer.get());
    }
}
